MySQL grouping by a previously declared alias, what do I wrap it in? ' OR `

Posted by cgmojoco on Stack Overflow See other posts from Stack Overflow or by cgmojoco
Published on 2010-04-07T21:31:36Z Indexed on 2010/04/07 21:33 UTC
Read the original article Hit count: 136

Filed under:
|
|

I have an SQL query that has an alias in the SELECT statement

SELECT CONCAT(YEAR(r.Date),_utf8'-',_utf8'Q',QUARTER(r.Date)) AS 'QuarterYear'

Later, I want to refer to this in my group by statement.

I'm a little confused...should I wrap this with backticks, single quote or just leave it unwrapped int he group by

GROUP BY `QuarterYear `

or should I do this?: GROUP BY 'QuarterYear'

or just this?: GROUP BY QuarterYear

© Stack Overflow or respective owner

Related posts about mysql

Related posts about backticks